<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>YIX | Home</title>
		<link rel="stylesheet" href="css/all.css">
		<link rel="stylesheet" href="css/index.css">
		<link rel="stylesheet" href="layui/css/layui.css">
		<link rel="stylesheet" href="css/style.css">
		<script src="js/index.js" defer></script>
		<script src="layui/layui.js"></script>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body style="height: 2000px;">
		<canvas id="canvas"></canvas>
		<div class="liyi_nav">
			<ul class="layui-nav layui-anim layui-anim-down" style="background: rgba(0,0,0,0.3);" lay-filter="">
				<a href="index.html" class="logo">YIX</a>
				<li class="layui-nav-item"><a href="index.html"><i class="layui-icon">&#xe68e;</i>首页</a></li>
				<li class="layui-nav-item"><a href=""><i class="layui-icon">&#xe62e;</i>摸鱼</a></li>
				<li class="layui-nav-item"><a href=""><i class="layui-icon">&#xe687;</i>社区</a></li>
				<li class="layui-nav-item">
					<a href="javascript:;"><i class="layui-icon">&#xe687;</i>学习资料</a>
					<dl class="layui-nav-child">
						<!-- 二级菜单 -->
						<dd><a href="">移动模块</a></dd>
						<dd><a href="">后台模版</a></dd>
						<dd><a href="">电商平台</a></dd>
					</dl>
				</li>
				<li class="layui-nav-item"><a href=""><i class="layui-icon">&#xe62a;</i>留言板</a></li>
				<div style="float: right;margin-right: 2px;">
					<li class="layui-nav-item layui-this">
						<a href="#"><i class="layui-icon">&#xe63a</i>消息<span class="layui-badge" id="messageStatus"
								style="display:none;">1</span></a>
					</li>
					<li class="layui-nav-item">
						<a href="">个人中心<span class="layui-badge-dot"></span></a>
					</li>
					<li class="layui-nav-item" id="zt">
						<a href="/home/yi">登录/注册</a>
					</li>
				</div>
			</ul>
			<script>
				layui.use('element', function() {
					var element = layui.element;
				});
			</script>
		</div>
		<div class="liyi_content">
			<div class="title">
			</div>
		</div>
		<div class="liyi_center">
			<canvas id="canvas2"></canvas>
			<script>
				/* Millennium Falcon with Pure CSS */
				/* Starfield with Canvas Javascript */

				const canvasa = document.querySelector("#canvas2");
				const ctxa = canvasa.getContext("2d");
				canvasa.width = 1920 - 40;
				canvasa.height = 1080 - 160;

				const MAX_STARS = 250;
				const STAR_COLORS = ["#444", "#888", "#FFF"];

				class Stars {
					constructor() {
						this.stars = [];
						for (let i = 0; i < MAX_STARS; i++) {
							const x = ~~(Math.random() * canvasa.width);
							const y = ~~(Math.random() * canvasa.height);
							const speed = ~~(1 + Math.random() * 5);
							const color = ~~(Math.random() * 3);
							this.stars.push({
								x,
								y,
								speed,
								color
							});
						}
					}

					draw() {
						for (let i = 0; i < MAX_STARS; i++) {
							const star = this.stars[i];
							ctxa.lineWidth = 1;
							ctxa.strokeStyle = STAR_COLORS[this.stars[i].color];
							ctxa.strokeRect(star.x, star.y, 1, 1);
						}
					}

					update() {
						for (let i = 0; i < MAX_STARS; i++) {
							this.stars[i].y += this.stars[i].speed;
							const isOutScreen = this.stars[i].y > canvasa.height;
							isOutScreen && (this.stars[i].y = 0);
						}
					}
				}


				const stars = new Stars();


				const clearScreen = () => ctxa.clearRect(0, 0, canvasa.width, canvasa.height);

				const loop2 = () => {
					clearScreen();
					requestAnimationFrame(loop2);
					stars.update();
					stars.draw();
				};

				loop2();
			</script>
		</div>
	</body>
</html>
<script src="js/script.js"></script>
<script>
	$datas = "";
	(function load() {
		$.ajax({
				url: "http://localhost:90/home/mysql_php/setcookie.php",
				type: "POST",
				data: {},
				success: function(res) {}
		})
		$.ajax({
			url: "http://localhost:90/home/mysql_php/setcookie.php",
			type: "POST",
			data: {},
			success: function(res) {
				if (res) {
					$data = JSON.parse(res);
					if ($data != "") {
						$.ajax({
							url: "http://localhost:90/home/mysql_php/demo_select.php",
							type: "POST",
							data: {
								userid: $data
							},
							success: function(res) {
								$bete = JSON.parse(res);
								if ($bete["status"] == 200) {
									$datas = $bete["data"][0];
									$("#zt").html(`<a href="#"><img src="upload/${$bete["data"][0]["imageicon"]}" class="layui-nav-img">${$bete["data"][0]["author"]}</a>
									    <dl class="layui-nav-child">
									      <dd><a href="javascript:;">修改信息</a></dd>
									      <dd><a href="javascript:;">安全管理</a></dd>
									      <dd><a href="javascript:;" onclick="removes()">退了</a></dd>
									    </dl>`)
								} else {
									if ($bete["status"] == 500) {
										alert("请勿修改登录session，cookie文件,重新登录!");
										removecookie();
										}
								}
							}
						})
					} else {
						console.log(window.location.href)
					}
				}
			}
		})

	})();
	var zt = document.getElementById("zt");

	function removecookie() {
		$.ajax({
			url: "http://localhost:90/home/mysql_php/removes.php",
			type: "POST",
			data: {},
			success: function(res) {
				if (res) {
					$data = JSON.parse(res);
					if ($data) {
						layui.use('layer', function() {
							var layer = layui.layer;
							location.reload();
						});
					}
				}
			}
		})
	}




	function removes() {
		if (confirm("确认退出登录?")) {
			removecookie();
		} else {
			layer.msg("取消退出登录操作");
		}

	}
</script>
